package cn.tedu.coolshark.Controller;

import cn.tedu.coolshark.mapper.CategoryMapper;
import cn.tedu.coolshark.pojo.entity.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
/**
 * @author 作者：HeShaoShuai
 * @Email 邮箱：2569819541@qq.com
 * @Date 日期：2023/5/18 17:03
 * @Package 包名：cn.tedu.coolshark.Controller
 * @Project 项目名：JavaSE
 * @Version 1.0
 */
@RestController
@RequestMapping("/category/")
public class CategoryController {
	@Autowired(required = false)
	CategoryMapper mapper;
	@RequestMapping("select")
	public List<Category> select(){
		return mapper.select();
	}
	@RequestMapping("delete")
	public void delete(int id){
		mapper.deleteById(id);
	}
	@RequestMapping("insert")
	public List<Category> insert(String name){
		mapper.insert(name);
		return mapper.select();
	}
	@RequestMapping("update")
	public void update(@RequestBody Category category){
		mapper.update(category);
	}
}